package com.graduation_design.modules.admin.controller;

import com.graduation_design.common.dto.AppSkuDto;
import com.graduation_design.common.lang.Result;
import com.graduation_design.modules.app.controller.BaseController;
import com.graduation_design.service.AppSkuStockService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/sku")
public class AdminSkuController extends BaseController {

    @Resource
    AppSkuStockService appSkuStockService;

    @GetMapping("/product/{productId}")
    public Result sku(@PathVariable Long productId) {
        return Result.success(appSkuStockService.getSkuByProductId(productId));
    }

    @PostMapping("/saveSku")
    public Result saveSku(@RequestBody AppSkuDto appSkuDto) {
        appSkuStockService.saveSku(appSkuDto);
        return Result.success(appSkuDto);
    }
}
